<!--职业管理-->
<template>
  <div style="background-color:#ffffff;">
    <el-row class="top_row">
      <el-col :span="24">
        <div class="top_title">
          <div class="left_add">
            <el-button
              type="info"
              @click="$router.push('/User/PositionEdit')"
              size="mini"
              icon="el-icon-circle-plus"
            >新增</el-button>
          </div>
          <div class="right_sel">
            <el-input size="mini" v-model="SelName" placeholder="查找...">
              <el-button slot="append" @click="SelDt" icon="el-icon-search" style="width:50px;"></el-button>
            </el-input>
          </div>
        </div>
      </el-col>
    </el-row>
    <hr />
    <el-table
      :data="PositionLifo"
      :default-sort="{prop: 'date', order: 'descending'}"
      style="width: 100%;height：200x;"
    >
      <el-table-column prop="pk_Position" label="ID" width="300"></el-table-column>
      <el-table-column prop="Title" label="名称" min-width="300"></el-table-column>
      <el-table-column prop="LevelID" label="层级" width="200"></el-table-column>
      <el-table-column prop="operation" label="操作" fixed="right" min-width="200" align="center">
        <template slot-scope="scope">
          <el-button type="primary" @click="Update(scope.row.pk_Position)"  class="el-icon-edit-outline" size="mini">修改</el-button>
           <el-popconfirm @onConfirm="Delete(scope.$index,scope.row.pk_Position)" style="margin-left:10px;"
                  :title="'确定删除此?'">
                  <el-button slot="reference" type="danger" size="mini" icon="el-icon-delete">删除</el-button>
            </el-popconfirm>
        </template>
      </el-table-column>
      <!-- ecf0f5 -->
    </el-table>
  </div>
</template>
<style lang="scss" scoped>
.top_row {
  border-bottom: 1px solid #f7f7f7;
  padding-bottom: 10px;
  .top_title {
    .left_add {
      float: left;
    }
    .right_sel {
      float: right;
    }
  }
}
</style>
<script>
export default {
  data() {
    return {
      PositionLifo: [],
      SelName: "",
    }
  },
  mounted() {
    this.SelDt()
  },
  methods: {
    SelDt() {
      this.$axios({
        url: "/HrApi/Position/GetPositionList",
        method: "GET",
        params: {
          SelName:this.SelName
        },
      }).then((res) => {
        if (!res.data.code) {
          this.PositionLifo = res.data.data;
        } else {
          this.$message.error(res.data.msg);
        }
      })
    },
    Update(id){
      this.$router.push({
          path: "/User/PositionEdit",
          query: {
          pk_Position: id
        }
         })
    },
     Delete(index,pk_Position){
       this.$axios({
        url: '/HrApi/Position/DeletePosition',
        method: 'POST',
        data:this.$Qs.stringify( {
          pk_Position:pk_Position,
          pk_User:this.$store.state.UserInfo.pk_User
        })
      }).then(res => {
        if (!res.data.code) {
          this.$message.success(res.data.msg)
          this.SelDt();
        } else {
          this.$message.error(res.data.msg)
        }
      })
      }
  }
};
</script>

